<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
Cookie[] cookies=request.getCookies(); //读出用户硬盘上的Cookie，并将所有的Cookie放到一个cookie对象数组里面
Cookie sCookie=null; 
String svalue=null; 
String sname=null; 
String cookieName = null;
String cookiePassword = null;
if(null != cookies){
	for(int i=0;i<cookies.length;i++){    //用一个循环语句遍历刚才建立的Cookie对象数组
	sCookie=cookies[i];   //取出数组中的一个Cookie对象 
	sname=sCookie.getName(); //取得这个Cookie的名字
	svalue=sCookie.getValue(); //取得这个Cookie的内容
	if("wdssname".equals(sname)){
		cookieName =  svalue;
	} 
	if("wdsspwd".equals(sname)){
		cookiePassword =  svalue;
	} 
	}
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<%@ include file="include.jsp"%> 

<% 
  String info = (String)request.getAttribute("alert");
  if(null == info)
     info = "";
  String userName = (String)request.getAttribute("username");
  if(null == userName){
     if(null != cookieName){
     	userName = cookieName;
     }else{
     	userName = "";
     }
  }
  session.invalidate();
%>
<script language=JavaScript>
 <!--
if(self != top) top.location.href = window.location.href;
//-->
function checkform()
{
if(isNull(document.LoginForm.UserName.value)){
  alert("请输入用户名～！");
  document.all.UserName.focus();
  return false;
}
if(isNull(document.LoginForm.Password.value)){
  alert("请输入密码～！");
  document.all.Password.focus();
  return false;
}
return true;
}
function isNull(pvalue)
 {
   var RegularExp=/^\s*$/;
   if(RegularExp.test(pvalue))
   {
     return true;
   }
   return false;
 }
function submitPage(){
    var LoginForm = document.forms[0];
    if(checkform()){
       LoginForm.submit();
    }
	
}
function isEntry(e){
     if(document.all)e = event;
     if(e.keyCode==13) {
             submitPage();
     };
}
</script>
</head>
<body class="login_body">
<div class="login_parent">
    <form name="LoginForm" action="<%=basePath %>logon.do" method="post" id="login_form">
       
            用户名<input name="UserName" type="text" value="<%=userName==null?"":userName %>" class="name"/><br />
            密　码<input name="Password" type="password" class="pass" value="<%=cookiePassword==null?"":cookiePassword %>"/><br />
            <span><input name="rememberme" type="checkbox" value="1" <%if(null != cookieName){out.println(" checked");} %>/> 保留用户名密码</span><font color=red><%=info %></font> <br />   
            <p><input name="" onclick="submitPage();" type="button" class="login"/><input   type="button" onclick="window.close();" class="cancel"/></p>
        
        
    </form>
    <div class="copy_right"><spring:message code="sys.copyright" /></div>
</div>
</body>
</html>
